Contents | Index | < Browse | Browse >

LETTERdivULETTER Computes the quotient and the remainder of two integers.

Overview
#include <stdlib.h>

x = div(numerator, denominator)

div_t x; // quotient and remainder
int numerator; // numerator
int denominator; // denominator

Portability
ANSI

Description
Common division routines calculate the quotient and remainder at once, it's a waste of time to compute these in two seperated steps. The "div_t" structure will contain the entries "quot" for the quotient and "rem" for the remainder.

Returns
The "div" function returns a structure of the div_t type:
typedef struct {
int rem;
int quot;
} div_t;

See also
ldiv